import request from '@/utils/request'

// 查询源模型列表
export function listSourceModel(query) {
  return request({
    url: '/model/source/list',
    method: 'get',
    params: query
  })
}

// 查询源模型详细
export function getSourceModel(id) {
  return request({
    url: `/model/source/${id}`,
    method: 'get'
  })
}

// 新增源模型
export function addSourceModel(data) {
  return request({
    url: '/model/source',
    method: 'post',
    data: data,
    headers: {
      'Content-Type': 'multipart/form-data'
    }
  })
}

// 修改源模型
export function updateSourceModel(data) {
  return request({
    url: '/model/source',
    method: 'put',
    data: data
  })
}

// 删除源模型
export function deleteSourceModel(ids) {
  return request({
    url: `/model/source/${ids}`,
    method: 'delete'
  })
}

// 下载源模型文件
export function downloadSourceModel(id) {
  return request({
    url: `/model/source/download/${id}`,
    method: 'get',
    responseType: 'blob'
  })
}

// 获取模型状态
export function getModelStatus(id) {
  return request({
    url: `/model/source/status/${id}`,
    method: 'get'
  })
}

// 激活/停用模型
export function changeModelStatus(id, status) {
  return request({
    url: `/model/source/status/${id}`,
    method: 'put',
    data: { status }
  })
}